import { NextRequest, NextResponse } from 'next/server';

export function middleware(request: NextRequest) {
  // 只处理页面路径，不影响API请求
  const { pathname } = request.nextUrl;
  
  // 如果是API请求或静态资源，直接通过
  if (
    pathname.startsWith('/api') ||
    pathname.startsWith('/_next') ||
    pathname.startsWith('/uploads') ||
    pathname.includes('.') ||
    pathname.startsWith('/socket.io') ||
    pathname.startsWith('/realtime')
  ) {
    return NextResponse.next();
  }

  return NextResponse.next();
}

export const config = {
  matcher: '/((?!_next/static|_next/image|favicon.ico).*)',
};
